package com.xpffly.design.iterator.common.service.impl;

import com.xpffly.design.iterator.common.service.Aggregate;
import com.xpffly.design.iterator.common.service.Iterator;

import java.util.Vector;

/**
 * @Author: xpengfei
 * @Date: 2021/4/13 23:55
 * @Description：
 */
public class ConcreteAggregate implements Aggregate {
    /**
     * 容纳对象的容器
     */
    private Vector vector = new Vector();

    /**
     * 添加元素
     *
     * @param object
     */
    public void add(Object object) {
        this.vector.add(object);
    }

    /**
     * 删除元素
     *
     * @param object
     */
    public void remove(Object object) {
        this.vector.remove(object);
    }

    /**
     * 遍历所有元素
     *
     * @return
     */
    public Iterator iterator() {
        return new ConcreteIterator(this.vector);
    }

}
